<!--
 * @Author: zk
 * @Date: 2021-02-24 16:09:21
 * @LastEditors: zk
 * @LastEditTime: 2021-02-26 11:45:07
 * @Description:
-->
<template>
  <el-dialog
    v-bind="$attrs"
    :title="title"
    :close-on-click-modal="false"
    top="0"
    :visible.sync="visible"
    class="log-dynamic"
    :before-close="handleClose"
  >
    <template v-slot:title>
      <slot name="title" />
    </template>
    <slot />
    <template v-slot:footer>
      <slot name="footer" />
    </template>
  </el-dialog>
</template>

<script>
import BeforeunLoadHandler from '@/mixin/BeforeunLoadHandler'
export default {
  mixins: [BeforeunLoadHandler],
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    }
  },
  data() {
    return {}
  },
  methods: {
    handleClose() {
      this.$confirm('确认关闭？')
        .then(_ => {
          this.$emit('update:visible', false)
        })
        .catch(_ => {})
      //
    },
    cancel() {
      this.handleClose()
    },
    // 确定按钮
    submit(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.handleClose()
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .el-dialog {
  position: absolute;
  top: 100px;
  left: 200px;
  right: 200px;
  bottom: 100px;
  margin: 0;
  width: auto;
  display: flex;
  flex-direction: column;
  // background: #a3ddfa;
  .el-dialog__header {
    background: rgb(6, 135, 209);
    padding-top: 10px;
    .el-dialog__title {
      font-size: var(--font-size-small-title);
      color: #fff;
    }
    .el-dialog__close {
      color: #fff;
      position: relative;
      top: -5px;
    }
  }
  .el-dialog__footer {
    box-shadow: 0px -1px 9px 0px #0687d1;
    background: rgb(245, 247, 250);
  }
  .el-dialog__body {
    padding: 30px 67px;
    height: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-top: 0;
    padding-bottom: 20px;
    font-size: var(--font-size-base);
    background: rgb(245, 247, 250);
    .el-tabs__item {
      font-size: var(--font-size-base);
    }
    .dynamic-content {
      height: 10px;
      flex: 1;
      overflow-y: auto;
      overflow-x: hidden;
    }
  }
}
</style>
